import http from '@/utils/http'
import type { ApiResponse } from '@/types/api';

// 医生查询请求参数接口
export interface DoctorRequest {
    /**
     * 科室
     */
    department?: string;
    /**
     * 擅长,模糊匹配
     */
    goodAt?: string;
    /**
     * 医生姓名,模糊匹配
     */
    name?: string;
    /**
     * 页码, 默认为1
     */
    pageNum?: string;
    /**
     * 每页大小，默认为10
     */
    pageSize?: string;
    /**
     * 职称
     */
    title?: string;
    [property: string]: any;
}

// 医生信息接口
export interface DoctorVO {
    /**
     * 医生ID
     */
    id: number;
    /**
     * 医生姓名
     */
    name: string;
    /**
     * 科室
     */
    department: string;
    /**
     * 头像
     */
    avatar?: string;
    /**
     * 职称
     */
    title: string;
    /**
     * 擅长领域
     */
    goodAt?: string;
    /**
     * 年龄
     */
    age?: number;
    /**
     * 性别
     */
    gender?: string;
    /**
     * 评分
     */
    rating?: number;
    [property: string]: any;
}

// 分页响应接口
export interface DoctorPageResponse {
    records: DoctorVO[];
    total: number;
    size: number;
    current: number;
    [property: string]: any;
}

// 获取医生列表
export const getDoctorList = (params: DoctorRequest): Promise<ApiResponse<DoctorPageResponse>> => {
    return http({
        url: '/user/appointment/doctorCard',
        method: 'GET',
        params
    })
}

// 获取医生详情
export const getDoctorDetail = (id: number): Promise<ApiResponse<DoctorVO>> => {
    return http({
        url: `/user/appointment/doctorDetail/${id}`,
        method: 'GET'
    })
}

// 预约医生请求参数接口
export interface AppointmentRequest {
    doctorId: number;
    [property: string]: any;
}

// 预约医生
export const appointDoctor = (doctorId: number): Promise<ApiResponse<any>> => {
    return http({
        url: `/user/appointment/${doctorId}`,
        method: 'POST'
    })
}
